<template>
  <div class="page">
    <div class="logo-title">abcd69</div>
    <div class="ipt-box">
      <div class="ipt-main">
        <div class="ipt-item">
          <div class="ipt-item-title">Enter your email</div>
          <van-field class="ipt-item-input" v-model="email" />
        </div>
        <div class="ipt-item">
          <div class="ipt-item-title">Enter your password</div>
          <van-field
            class="ipt-item-input"
            type="password"
            v-model="password"
          />
          <div class="forgot-text" @click="goForget">Forgot password</div>
        </div>
      </div>
      <div class="confirm-box">
        <van-button class="confirm-btn" @click="login">Log in</van-button>
        <van-button class="confirm-btn" @click="goRegister"
          >Register account</van-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { apiLoginApp } from "../../request/api";
export default {
  name: "login",
  data() {
    return {
      email: "",
      password: "",
      code: "",
    };
  },
  goLogin() {
    this.$router.push("/login");
  },
  created() {},
  mounted() {},
  methods: {
    goForget() {
      this.$router.push("/forget");
    },
    goRegister() {
      this.$router.push("/register");
    },
    login() {
      apiLoginApp({
        username: this.email,
        password: this.password,
      }).then((res) => {
        if (res.code == 200) {
          console.log(res);
          localStorage.setItem("key", res.token);
          // this.$toast.success(res.msg);
          // this.$toast.success("登录成功");
          this.$router.replace("/");
        } else {
          this.$toast.fail(res.msg);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.logo-title {
  font-size: 70px;
  font-weight: 800;
  color: #273458;
  margin: 166px auto 194px;
  text-align: center;
}
.ipt-item-input {
  border: 1px solid #a6a6a6;
  height: 90px;
  align-items: center;
}
:deep(.van-field__control) {
  font-size: 28px;
}
.ipt-box {
  padding: 0 56px;
  .ipt-main {
    .ipt-item {
      margin-bottom: 40px;
    }
    .ipt-item-title {
      color: #273458;
      font-size: 28px;
      font-weight: bold;
      margin-bottom: 20px;
    }

    .forgot-text {
      font-size: 24px;
      font-weight: 400;
      color: #273458;
      text-align: right;
      margin-top: 15px;
    }
  }
  .confirm-box {
    margin-top: 170px;
    .confirm-btn {
      width: 100%;
      height: 90px;
      background: #273458;
      box-shadow: 0px 3px 12px 1px rgba(71, 71, 71, 0.16);
      border: 1px solid #ffffff;
      font-size: 26px;
      color: #ffffff;
      font-weight: 400;
      margin-bottom: 20px;
    }
  }
}
</style>
